﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Web;

namespace businessLayer
{
    [DataContract]
    public class Klanten
    {
        [DataMember]
        public int klantnr { get; set; }
        [DataMember]
        public string naam { get; set; }
        [DataMember]
        public string voornaam { get; set; }
        [DataMember]
        public string adres { get; set; }
        [DataMember]
        public string postcode { get; set; }
        [DataMember]
        public string telefoon { get; set; }
        [DataMember]
        public string email { get; set; }
        [DataMember]
        public float getrouwheidsKm { get; set; }
    }

    

    public class KlantenDB 
    {
       /* public static Klanten GetKlantById(int Id)
        {
            SqlConnection myConn = null;
            Klanten huidigeKlant = new Klanten();
            try
            {
                using (myConn = new SqlConnection(BPcars.GetConnection()))
                {
                    string selectCommand = "Select * from Klanten WHERE Klantnr = @Klantnr";
                    SqlCommand mycommand = new SqlCommand(selectCommand, myConn);
                    mycommand.Parameters.AddWithValue("@Klantnr", Id);

                    myConn.Open();

                    SqlDataReader myReader = mycommand.ExecuteReader();

                    if (myReader.Read())
                    {
                        int id = (int)myReader[1];
                        huidigeKlant.naam = (string)myReader[2];
                        huidigeKlant.voornaam = (string)myReader[3];
                        huidigeKlant.adres = (string)myReader[4];
                        huidigeKlant.postcode = (string)myReader[5];
                        huidigeKlant.telefoon = (string)myReader[6];
                        huidigeKlant.email = (string)myReader[7];
                        huidigeKlant.getrouwheidsKm = (float)myReader[8];
                    }
                }
            }
            catch (SqlException ex)
            {
                throw;
            }
            return huidigeKlant;
        }*/

        
        /*public IEnumerable<Klanten> GetAlleKlanten()
        {
            List<Klanten> KlantenLijst = new List<Klanten>();
            SqlConnection myConn = null;
            Klanten alle = new Klanten();
            try
            {
                using (myConn = new SqlConnection(BPcars.GetConnection()))
                {
                    myConn.Open();

                    var cmd = new SqlCommand("Select * from Klanten",myConn);
                    var reader = cmd.ExecuteReader();

                  

                    while (reader.Read())
                    {
                        int klantnr = Convert.ToInt32(reader["klantnr"]);
                        string naam = Convert.ToString(reader["naam"]);
                        string voornaam = Convert.ToString(reader["voornaam"]);
                        string adres = Convert.ToString(reader["adres"]);
                        string postcode = Convert.ToString(reader["postcode"]);
                        string telefoon = Convert.ToString(reader["telefoon"]);
                        string email = Convert.ToString(reader["email"]);
                        float getrouwheidsKm = (float)reader["getrouwheidsKm"];
                     
        

                    }

                    reader.Close();
                    cmd.Dispose();
                   
                   

                  
                }
            }
            catch (SqlException ex)
            {
                throw;
            }
            return KlantenLijst;
        }*/
    }

}